Skip to content
This repository has been archived by the owner on Sep 1, 2020. It is now read-only.

Latest commit

 

History

History
22 lines (16 loc) · 845 Bytes

8.2.1 - WebSocket/Server->push.md

File metadata and controls

22 lines (16 loc) · 845 Bytes

WebSocket\Server->push

WebSocket\Server->push1.7.11以上版本可用

websocket客户端连接推送数据,长度最大不得超过2M

function WebSocket\Server->push(int $fd, $data, int $opcode = 1, bool $finish = true);

参数模式1

  • $fd 客户端连接的ID,如果指定的$fd对应的TCP连接并非websocket客户端,将会发送失败
  • $data 要发送的数据内容
  • $opcode,指定发送数据内容的格式,默认为文本。发送二进制内容$opcode参数需要设置为WEBSOCKET_OPCODE_BINARY
  • 发送成功返回true,发送失败返回false

参数模式2

需要4.2.0及以上版本